package cn.bx.bid.service;

import cn.bx.bid.dao.ProfessorDao;
import cn.bx.bid.entity.Page;
import cn.bx.bid.entity.Professor;
import cn.bx.bid.entity.Project;
import cn.bx.bid.entity.WorkHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//M V C
@Service
public class ProfessorService {
	public static final int PAGE_SIZE = Page.PAGE_SIZE;
@Autowired
private ProfessorDao professorDao;
	public int add(Professor p) {
			return professorDao.add(p);
	}
	public int update(Professor p) {
		return professorDao.update(p);
	}

	public int batchDel(long[] ids) {
			return professorDao.batchDel(ids);
	}

	public Page<Professor> paging(int pageNo, int limit, String name, String tele,String id) {
			List<Professor> list = professorDao.search(pageNo, limit, name, tele, id);
			int total = professorDao.searchTotal(name, tele, id);
			Page<Professor> p = new Page<Professor>(total, limit, list);
			return p;
	}

    public Professor get(long id) {
			Professor p = professorDao.get(id);
			return p;
    }

	public WorkHistory getOneHistory(long id) {
		WorkHistory history = professorDao.getOneHistory(id);
		return history;
	}

	public int addHistory(WorkHistory w) {
			int p = professorDao.addHistory(w);
			return p;
	}

	public int updateHistory(WorkHistory w) {
			int p = professorDao.updateHistory(w);
			return p;
	}

	public int delHis(long id, long hisid) {
			int p = professorDao.delHis(id,hisid);
			return p;
	}

	public List<Project>  findProjs(long  profid) {
			List<Project> p = professorDao.findProjs(profid);
			return p;
	}
}
